package com.xlh.param.course;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.xlh.util.InputValidator;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 课程参数
 * <p>
 * Created by lx on 2019/2/26.
 */
@Data
public class CourseParam {

    @ApiModelProperty(value = "课程名称")
    @NotBlank(message = "课程名称不能为空")
    @Length(max = 20, message = "课程名称不能超过20个字符")
    private String name;

    @ApiModelProperty(value = "类型")
    @JsonIgnore
    private Integer type;

    @ApiModelProperty(value = "类型名称")
    @Length(max = 15, message = "类型不能超过15个字符")
    private String typeName;

    @ApiModelProperty(value = "图标id")
    @NotNull(message = "图标不能为空")
    private Integer icon;

    @ApiModelProperty(value = "简介")
    @Length(max = 200, message = "简介不能超过200个字符")
    private String introduction;

    @ApiModelProperty(value = "课程方向")
    @NotNull(message = "课程方向不能为空")
    private List<Long> directionIds;

    @ApiModelProperty(value = "镜像加载类型字符串")
    @NotNull(message = "镜像加载类型不能为空")
    private String imageLoadTypeStr;

    @ApiModelProperty(value = "镜像加载类型")
    @JsonIgnore
    private Integer imageLoadType;

    public String getName() {
        return name == null ? null : InputValidator.regSpecialChar(name);
    }

}
